package org.example.controller;

import io.swagger.annotations.ApiOperation;
import org.example.config2.MyWebAuthenticationDetails;
import org.example.pojo.AdminLoginParam;
import org.example.pojo.RespBean;
import org.springframework.security.core.Authentication;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.security.Principal;

/**
 * @Auther: GongXl
 * @Date: 2021/3/8 23:36
 * @Description:
 */
@Controller
public class LoginController {
//    @RequestMapping("/login")
//    public RespBean login(AdminLoginParam adminLoginParam, HttpServletRequest request){
//        return null;
//    }
    /**
     * @Author GongXl
     * @Description 退出功能
     * @Date 2021/3/27 10:43
     * @Param []
     * @return org.example.pojo.RespBean
     **/
    /*@ApiOperation(value = "退出登录")
    @RequestMapping("/logout")
    @ResponseBody
    public void logout(){
        System.out.println("注销成功");
    }*/
    @RequestMapping("/getUserInfo")
    @ResponseBody
    public Principal getMyWebAuthenticationDetails(Principal principal){
        if(null != principal){
            String username = principal.getName();
            //TODO 查询用户信息
        }
        return principal;
    }
    @RequestMapping("/toMain")
    public String toMain(){
        return "redirect:main.html";
    }
    @RequestMapping("/toError")
    public String toError(){
        return "redirect:error.html";
    }
    @RequestMapping("/demo")
    public String toDemo(){
        return "demo";
    }
    @RequestMapping("/showLogin")
    public String showLogin(){
        return "login";
    }

}